﻿'Imports System.Data.SqlClient
'Imports System.Data
'Imports System.Configuration
'Public Class DataProvider
'    Public Shared Function GetConnectionString(ByVal strConnection As String) As String
'        'Declare a string to hold the connection string
'        Dim sReturn As New String("")
'        'Check to see if they provided a connection string name
'        If Not String.IsNullOrEmpty(strConnection) Then
'            'Retrieve the connection string fromt he app.config
'            sReturn = ConfigurationManager.ConnectionStrings(strConnection).ConnectionString
'        Else
'            'Since they didnt provide the name of the connection string
'            'just grab the default on from app.config
'            sReturn = ConfigurationManager.ConnectionStrings("QLThueNha").ConnectionString
'        End If
'        'Return the connection string to the calling method
'        Return sReturn
'    End Function

'    Dim str As String = GetConnectionString("QLThueNha")
'    Private cn As SqlConnection

'    Public Function Connect() As Boolean
'        cn = New SqlConnection(str)
'        Try
'            cn.Open()
'        Catch ex As Exception
'            System.Windows.Forms.MessageBox.Show("Không thể kết nối tới database! " = ex.Message)
'        End Try
'        Return True
'    End Function
'    Public Sub Close()
'        If cn.State = ConnectionState.Open Then
'            cn.Close()
'        End If
'        cn.Dispose()
'    End Sub

'    Public Function GetData(ByVal Sql As String) As DataTable
'        cn = New SqlConnection(str)
'        Connect()
'        Dim da As SqlDataAdapter = New SqlDataAdapter(Sql, cn)
'        Dim dt As New DataTable()
'        da.Fill(dt)
'        Close()
'        Return dt
'    End Function
'    Public Function LoadLoaiPhong(ByVal sql As String) As DataSet
'        Dim ds As New DataSet()
'        Connect()
'        'cmd = New SqlCommand(sql, cn)
'        Dim da As New SqlDataAdapter(sql, cn)
'        da.Fill(ds, "LOAIPHONG")
'        Close()
'        Return ds
'    End Function
'    Public Function LoadQuan(ByVal sql As String) As DataSet
'        Dim ds As New DataSet()
'        Connect()
'        'cmd = New SqlCommand(sql, cn)
'        Dim da As New SqlDataAdapter(sql, cn)
'        da.Fill(ds, "QUAN")
'        Close()
'        Return ds
'    End Function
'    Public Function LoadDonVi(ByVal sql As String) As DataSet
'        Dim ds As New DataSet()
'        Connect()
'        Dim da As New SqlDataAdapter(sql, cn)
'        da.Fill(ds, "DONVI")
'        Close()
'        Return ds
'    End Function
'    Public Function LoadLNV(ByVal sql As String) As DataSet
'        Dim ds As New DataSet()
'        Connect()
'        Dim da As New SqlDataAdapter(sql, cn)
'        da.Fill(ds, "LOAINHANVIEN")
'        Close()
'        Return ds
'    End Function
'    Public Sub CreateCommand(ByVal queryString As String, ByVal connectionString As String)
'        Using connection As New SqlConnection(connectionString)
'            Dim command As New SqlCommand(queryString, connection)
'            command.Connection.Open()
'            command.ExecuteNonQuery()
'            command.Connection.Close()
'        End Using
'    End Sub

'    Public Sub ExecSql(ByVal Sql As String)
'        Dim cn As SqlConnection = New SqlConnection(str)
'        Connect()
'        'Dim cmd As SqlCommand = New SqlCommand(Sql, cn)
'        'cmd.ExecuteNonQuery()
'        CreateCommand(Sql, str)
'        'Close()
'    End Sub
'End Class
